package com.jt.controller;

import com.jt.pojo.Dept;
import com.jt.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dept")
@CrossOrigin
public class DeptController {
    @Autowired
    private DeptService deptService;

    @GetMapping("/getAll")
    public List<Dept> getAll(){
        return deptService.getAll();
    }

    @DeleteMapping("/deleteDept")
    public String deleteDept(Integer id){
        deptService.deleteDept(id);
        return "删除成功";
    }

    @PostMapping("/saveDept")
    public String saveDept(@RequestBody Dept dept){
        deptService.saveDept(dept);
        return "插入成功";
    }

    @PutMapping("/updateDept")
    public String updateDept(@RequestBody Dept dept){
        deptService.updateDept(dept);
        return "修改成功";
    }

}
